<template>
  <div class="form-setting-panel form-currency-setting">
    <!-- start 标题 -->
    <form-title-setting 
			:field="field" 
			:mode="mode" 
			:setting="setting" 
			@input="updateForDom"
		>
		</form-title-setting>
    <!-- end 标题 -->

    <!-- start 帮助提示 -->
    <form-describe-setting
      :field="field"
      :mode="mode"
			:title="t('common.base.helpTips')"
			:placeHolder="t('common.placeholder.inputCurrency')"
      @input="updateForDom"
    ></form-describe-setting>
    <!-- end 帮助提示 -->

    <!-- start 默认币种 -->
    <form-default-currency-setting
      :field="field"
      :mode="mode"
      @input="update"
    ></form-default-currency-setting>
    <!-- end 默认币种 -->

    <!-- start 校验 -->
    <div class="form-setting-group form-setting-item">
      <h4 class="form-item-title">{{ $t('common.base.check') }}</h4>
      <div class="form-item-box">
        <!-- 必填 -->
        <form-required-setting :field="field" @input="update"></form-required-setting>
      </div>
    </div>
    <!-- end 校验 -->

    <!-- start 默认值 -->
    <form-default-value-setting
      :field="field"
      :max-length="maxLength"
      type="number"
      @input="update"
    ></form-default-value-setting>
    <!-- end 默认值 -->

    <!-- start 字段权限 -->
    <div class="form-setting-group form-setting-item" v-if="!isServiceProviderFlag">
      <h4 class="form-item-title">{{ $t('common.base.fieldPermissions') }}</h4>
      <div class="form-item-box">
        <!-- 移动端列表展示 -->
        <mobile-show-setting v-if="isTaskMode" :field="field" :fields="fields" @input="update"></mobile-show-setting>
        <!-- 可见性 -->
        <form-visible-setting :field="field" @input="update"></form-visible-setting>
        <!-- 支持高级搜索 -->
        <form-search-setting :field="field" @input="update" v-if="!isTaskCardForm"></form-search-setting>
        <!-- 是否对客户可见 -->
         <form-visible-customer-setting :field="field" @input="update" v-if="isTaskModeForVisibleCustomer"></form-visible-customer-setting>
      </div>
    </div>
    <!-- end 字段权限 -->
  </div>
</template>

<script>
import SettingMixin from '@src/component/form/mixin/setting';
import { settingProps } from '@src/component/form/components/props';
import { FORM_FIELD_NUMBER_MAX_LENGTH } from '@src/model/const/Number.ts';

export default {
  name: 'form-currency-setting',
  mixins: [SettingMixin],
  props: settingProps,
	computed: {
    maxLength() {
      return FORM_FIELD_NUMBER_MAX_LENGTH;
    },
	},
  methods: {
    updateForDom(event) {
      let el = event.target;
      let prop = el.dataset.prop;
      let value = el.value;

      this.update(value, prop);
    },
    update(value, prop, isSetting = false) {
      this.$emit('input', { value, prop, isSetting });
    },
  },
};
</script>
